package com.example.exerciseextract.fragment1;


import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.example.exerciseextract.R;
import com.example.exerciseextract.adapter.RvAdapter;
import com.example.exerciseextract.bean.RvBean;
import com.example.exerciseextract.presenter.MainPresenter;
import com.example.exerciseextract.view.NetView;

import java.util.ArrayList;

/**
 * A simple {@link Fragment} subclass.
 */
public class HomeFragment extends Fragment implements NetView {


    private View view;
    private RecyclerView mRv;
    private ArrayList<RvBean.DataBean.DatasBean> list;
    private MainPresenter mainPresenter;
    private RvAdapter rvAdapter;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
        View inflate = inflater.inflate(R.layout.fragment_home, container, false);
        initView(inflate);
/*        mainPresenter = new MainPresenter(this);
        mainPresenter.setData();*/
        return inflate;
    }

    private void initView(View inflate) {
        mRv = (RecyclerView) inflate.findViewById(R.id.rv);
        mRv.setLayoutManager(new LinearLayoutManager(getActivity()));
        list = new ArrayList<>();
        rvAdapter = new RvAdapter(getContext(),list);
        mRv.setAdapter(rvAdapter);
    }

/*
    @Override
    public void setData(ArrayList<RvBean.DataBean.DatasBean> databean) {

        list.addAll(databean);
        rvAdapter.notifyDataSetChanged();

    }
*/

    @Override
    public void setData(RvBean databean) {

    }

    @Override
    public void shoutow(String string) {

        Toast.makeText(getActivity(), string, Toast.LENGTH_SHORT).show();
    }
}
